package com.huluobo.day11_im.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.huluobo.day11_im.IMApp;
import com.huluobo.day11_im.R;
import com.huluobo.day11_im.fragment.ChatFragment;

public class ChatActivity extends AppCompatActivity {

    private ImageView back;
    private TextView title;

    private ChatFragment chatFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);

        back = findViewById(R.id.header_back);
        back.setVisibility(View.VISIBLE);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        title = findViewById(R.id.main_title);
        title.setText(getIntent().getExtras().getString(IMApp.CHAT_CONVERSATION_ID));

        chatFragment = new ChatFragment();
        chatFragment.setArguments(getIntent().getExtras());//给fragment传递intent中bundle所有值
        getSupportFragmentManager().beginTransaction().add(R.id.chat_container, chatFragment).commit();
    }
}